"""
校验位计算方法
https://zhidao.baidu.com/question/345992709.html

"""

"""
12位校验位计算方法
"""


def get_check_bit(app_no):
    if len(app_no) == 12:
        # 12位按位乘规则
        num = "234567892345"
        allnum = 0
        for i, j in zip(app_no, num):
            allnum += int(i) * int(j)
        mode = allnum % 11
        if mode == 10:
            mode = "X"
        return "CN{}.{}".format(app_no, mode)
    elif len(app_no) == 8:
        # 8位按位乘规则
        num = "23456789"
        allnum = 0
        for i, j in zip(app_no, num):
            allnum += int(i) * int(j)
        mode = allnum % 11
        if mode == 10:
            mode = "X"
        return "CN{}.{}".format(app_no, mode)


#	 CN201720180111.4
print(get_check_bit("201810495297"))
